<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"> 
  <meta name="”renderer”" content="”webkit”"> 
  <meta http-equiv="”X-UA-Compatible”" content="”IE=Edge,chrome=1″"> 
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
  <title>小视频-视频列表</title> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/staticvideoclip/portal/layui/css/layui.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/staticvideoclip/portal/css/le-main.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/staticvideoclip/portal/css/alliance-market.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/staticvideoclip/libs/font-awesome-4.7.0/css/font-awesome.min.css?cdnv=0.16"> 
  <style type="text/css">
    </style> 
 </head> 
 <body> 
  <div class="le-main"> 
<%@include file="portal_navi.jsp" %>
   <div class="le-main fix"> 
    <div class="le-content-wrap le-head-content"> 
     <div class="le-sidebar"> 
      <ul class="layui-nav layui-nav-tree"> 
       <li class="layui-nav-item layui-this"> <a href="${ctx }/portal/videoClip/list.vo"><i class="fa fa-indent" aria-hidden="true"></i>&nbsp;小视频列表</a> </li> 
       <!-- <li class="layui-nav-item " id="videoClipSetting">
            <a href="video-clip-set.html"><i class="fa fa-wrench" aria-hidden="true"></i>&nbsp;小视频设置</a>
        </li>--> 
      </ul> 
     </div> 
     <div class="le-content "> 
      <div class="le-mall-content"> 
       <div> 
        <fieldset class="layui-elem-field layui-field-title"> 
         <legend>小视频列表 </legend> 
        </fieldset> 
        <ul class="le-hardware-content"> 
         <li class="le-add-hardware" layer-href="${ctx }/portal/videoClip/add.vo"> <a class="le-hardware-link" href="#"> <p><i class="fa fa-plus-circle fa-5x" aria-hidden="true"></i></p> <h3>新建小视频</h3> </a> </li> 
        </ul> 
       </div> 
       <div class="le-footer"> 
        <p>Copyright © 2015-2017 le.com.cn. All rights reserved.</p> 
       </div> 
      </div> 
     </div> 
    </div> 
   </div> 
   <script type="text/javascript" src="http://cdn.lezhibo.com/staticvideoclip/portal/layui/layui.js?cdnv=0.16"></script> 
   <script type="text/javascript" src="http://cdn.lezhibo.com/staticvideoclip/portal/layui/lay/dest/layui.all.js?cdnv=0.16"></script> 
   <script type="text/javascript" src="http://cdn.lezhibo.com/staticvideoclip/portal/js/jquery.min.js?cdnv=0.16"></script> 
   <script type="text/javascript" src="http://cdn.lezhibo.com/staticvideoclip/portal/js/jquery.form.min.js?cdnv=0.16"></script> 
   <script>
        var cdnPath="http://cdn.lezhibo.com";//cdn路径
        function fix() {
            var head_height = $('.le-head').outerHeight();
            var window_height = $(window).height();
            var content_height = $('.le-content').outerHeight();
            var sidebar_height = $(".le-sidebar").height();
            var max_height = window_height - head_height;
            if(content_height < sidebar_height){
                content_height = sidebar_height;
            }

            if(max_height < content_height){
                max_height = content_height;
            }

            $(".le-content").css('min-height', max_height);
            $(".le-sidebar").css('min-height', max_height);


//                if (content_height < (window_height - head_height)) {
//                    $(".le-content").css('min-height', window_height - head_height);
//                } else {
//                    $(".le-sidebar").css('min-height', content_height);
//                    sidebar_height = content_height;
//                }
//
//                if (sidebar_height < (window_height - head_height)) {
//                    $(".le-sidebar").css('min-height', window_height - head_height);
//                }
        }

        var globalNeedRefreshIndex = "";
        var globalNeedRefreshUrl = "";
        var needRefresh = false;

        function openLayer(url, title, func, isNeedRefreshThisPage) {
            var index = layer.open({
                type: 2,
                title: title,
                shadeClose: true,
                shade: 0.6,
                area: ['60%', '80%'],
                content: url,
                end: function () {
                    if (needRefresh) {
                        layer.iframeSrc(globalNeedRefreshIndex, globalNeedRefreshUrl);//刷新第几层
                        needRefresh = false;
                    }

                    if (!(typeof(func) == "undefined")) {
                        eval(func);
                    }
                }
            });

            if (isNeedRefreshThisPage == true) {
                globalNeedRefreshIndex = index;
                globalNeedRefreshUrl = url;
            }

        }

        function layerInit() {
            $("[layer-href]").click(function () {
                if ("" == $(this).attr("layer-need-record")) {
                    openLayer($(this).attr("layer-href"), $(this).attr("layer-title"), $(this).attr("layer-func"), true);
                } else {
                    openLayer($(this).attr("layer-href"), $(this).attr("layer-title"), $(this).attr("layer-func"), false);
                }
            });

            $("[go-href]").click(function () {
                var href = $(this).attr("go-href");
                var newWind = $(this).attr("go-href-new");
                if (newWind == "true") {
                    window.open(href);
                } else {
                    window.location.href = href;
                }
            });


            $("[confirm-href]").click(function () {
                var href = $(this).attr("confirm-href");
                if ((typeof(href) == "undefined") || href == null || href == "") {
                    return;
                }

                var title = $(this).attr("confirm-title");
                if ((typeof(title) == "undefined") || title == null || title == "") {
                    title = "您确定执行该操作吗？"
                }
                layer.confirm(title, {icon: 9, title: '确定操作 ？'}, function (index) {
                            layer.close(index);
                            $.get(href, function (result) {
                                if (result.isOk) {
                                    location.reload();
                                } else {
                                    alert(result.message);
                                }
                            });
                        },
                        function (index) {
                            layer.close(index);
                        });
            });


        }

        function headerFocus() {
            $("#nav-video-clip").addClass("layui-this");
        }


        function initSidebarUrls() {

            $(".le-sidebar").find(".layui-nav-item").each(function () {
                var pid = $(this).attr("id");
                if (typeof(pid) == 'undefined' || null == pid) {
                    return;
                }

                var href = $(this).children('a').attr("href");
                if ((typeof(href) != "undefined") && href.indexOf("?") == -1) {
                    href = href + "?p=" + pid;
                } else {
                    href = href + "&p=" + pid;
                }
                $(this).attr("class", "layui-nav-item");
                $(this).children('a').attr("href", href);
            });

            $("#").attr("class", "layui-nav-item layui-this");
        }

        var verification = {
            mobiel: function () {
                $mobile = $("input[validate='mobile']").val();
                var re = /^1\d{10}$/;
                if ((typeof($mobile) != "undefined") && !re.test($mobile)) {
                    $("input[validate='mobile']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入正确的手机号</span></p>');
                    return false;
                }
            },
            email: function () {
                $email = $("input[validate='email']").val();
                var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                if ((typeof($email) != "undefined") && !re.test($email)) {
                    $("input[validate='email']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入正确的邮箱</span></p>');
                    return false;
                }
            },
            empty: function () {
                var $input = $("input[validate='empty']");
                for (var i = 0; i < $input.length; i++) {
                    if ($input.eq(i).val().trim().length == 0) {
                        $("input[validate='empty']").eq(i).after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                        return false;
                    }
                }

                var $textarea =$("textarea[validate='empty']");
                for(var i=0;i<$textarea.length;i++){
                    if($textarea.eq(i).val().trim().length==0){
                        $("textarea[validate='empty']").eq(i).after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                        return false;
                    }
                }
            },

            password: function () {
                $password = $("input[validate='password']").val();
                var re = /(.+){6,12}$/;
                if ((typeof($password) != "undefined") && !re.test($password)) {
                    $("input[validate='password']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入6到12位密码</span></p>');
                    return false;
                }
            }
        }


        var regularVerify = {
            mobile: function (value) {
                var re = /^1\d{10}$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            email: function (value) {
                var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            password: function (value) {
                var re = /(.+){6,12}$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            integer: function (value)     {
//                    var re = /^[1-9]\d*$/;
                var re = /^\d+$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            decimal: function (value) {
//                    var re = /^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$/;
                var re = /^[0-9]+\.{0,1}[0-9]{0,2}$/;
                if ((typeof(value) != "undefined") && !re.test(value)) {
                    return false;
                }
            },
            empty: function (value) {
                if (value.trim().length == 0) {
                    return false;
                }
            }
        }


        function leSubmit() {
            $("[le-submit]").click(function () {
                var $form = $(this).parents("form");
                var sfunc = $form.attr("success-func");
                var bfunc = $form.attr("before-func");
                $form.ajaxSubmit({
                    type: "post",
                    dataType: "json",
                    beforeSend: function () {
                        if(bfunc != null){
                            if(false == eval(bfunc)){
                                return false;
                            }
                        }
                        $(".le-tips").remove();
                        if (false == verification.empty()) {
                            return false;
                        }
                        if (false == verification.mobiel()) {
                            return false;
                        }
                        if (false == verification.email()) {
                            return false;
                        }
                        if (false == verification.password()) {
                            return false;
                        }
                    },
                    success: function (result) {
                        if (sfunc != null) {
                            eval(sfunc);
                            return;
                        }

                        if (result.isOk) {
                            parent.isUpdateData = true;
                            parent.layer.closeAll();
                        } else {
                            alert(result.message);
                        }
                    },
                    error: function () {
                        alert("信息提交错误");
                    }
                });
            })
        }

        //对日期选择范围的控制
        //对id为begin-date和end-date的日期选择控件进行控制
        function verifyDate() {
            layui.use('laydate', function () {
                var laydate = layui.laydate;
                var start = {
                    min: '2006-01-01 00:00:00',
                    max: '2099-06-16 23:59:59',
                    istoday: false,
                    choose: function (datas) {
                        end.min = datas;    //开始日选好后， 重置结束日的最小日期
                        end.start = datas;  //将结束日的初始值设定为开始日
                    }
                };

                var end = {
                    min: '2006-01-01 00:00:00',
                    max: '2099-06-16 23:59:59',
                    istoday: false,
                    choose: function (datas) {
                        start.max = datas;  //结束日选好后, 重置开始日的最大日期
                    }
                };

                $('.begin-date').click(function () {
                    start.elem = this;
                    laydate(start);
                });
                $('.end-date').click(function () {
                    end.elem = this;
                    laydate(end);
                });

            });
        }

        fix();
        layerInit();
        headerFocus();
        initSidebarUrls();
        leSubmit();
        verifyDate();


//<script>
    layui.use('element', function () {
        var element = layui.element(); //Tab的切换功能，切换事件监听等，需要依赖element模块
    });
    //    最小高度控制
    function fix() {
        var head_height = $('.le-head').outerHeight();
        var window_height = $(window).height();
        var content_height = $('.le-content').outerHeight();
        var sidebar_height = $(".le-sidebar").height();

        if (content_height < (window_height - head_height)) {
            $(".le-content").css('min-height', (window_height - head_height));
        } else {
            $(".le-sidebar").css('min-height', content_height);
            sidebar_height = content_height;
        }

        if (sidebar_height < (window_height - head_height)) {
            $(".le-sidebar").css('min-height', (window_height - head_height));
        }

    }

    fix();
    //删除按钮
    $(".le-hardware-content li").hover(function(){
        $(this).find(".le-hardware-laythis-icon").show();
    },function(){
        $(this).find(".le-hardware-laythis-icon").hide();
    });

    /*点击图片进入编辑*/
    $(".le-loud-img").click(function () {
        console.log($(this).siblings(".le-hardware-laythis-icon").find(".edit-btn"));
        $(this).siblings(".le-hardware-laythis-icon").find(".edit-btn")[0].click();
    });
    //</script>  
  </div>   
 </body>
</html>